const imgUp = (req, res) => {
    // 判断文件是否过大,允许上传的文件类型
    let { size, mimetype, path } = req.file;
    let types = ['jpg', 'jpeg', 'png', 'gif', 'webp'];
    //截取到文件类型("mimetype": "image/jpeg"中的jpeg)
    let tmpType = mimetype.split("/")[1];
    if (size > 1024 * 800) {
        return res.json({
            status: -1,
            message: '尺寸过大',
        })
    } else if (types.indexOf(tmpType) == -1) {
        return res.json({
            status: -2,
            message: '媒体类型错误',
        })
    } else {
        res.json({
            status: 200,
            // path: 'http://120.78.9.102:8010' + '/uploads/' + req.file.filename
            path: 'http://127.0.0.1:3000' + '/uploads/' + req.file.filename
        })
    }
}
module.exports = {
    imgUp
}